import 'package:flutter/material.dart';

import 'package:junyeyishu/utils/utils.dart';

class QGSaleBuyCell extends StatefulWidget {
  dynamic data;

  QGSaleBuyCell({super.key, this.data});
  @override
  State<QGSaleBuyCell> createState() => QGSaleBuyCellState();
}

class QGSaleBuyCellState extends State<QGSaleBuyCell> {
  String? tradeTime;

  updateTradeTime() {
    tradeTime = getTradeTime(widget.data?["trade_time"]);
  }

  @override
  Widget build(BuildContext context) {
    updateTradeTime();
    return Container(
      margin: EdgeInsets.symmetric(horizontal: 15.rpx),
      padding: EdgeInsets.symmetric(vertical: 20.rpx),
      decoration: BoxDecoration(
          border: Border(
              bottom:
                  BorderSide(width: 0.5.rpx, color: const Color(0xFFEAEAEA)))),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          SizedBox(
            width: 80.rpx,
            child: Text(
              "$tradeTime前",
              style: TextStyle(
                  color: const Color(0xffffffff),
                  fontSize: 14.rpx,
                  fontWeight: FontWeight.normal),
            ),
          ),
          SizedBox(height: 6.rpx),
          Expanded(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  "#${widget.data?["nft_no"]}",
                  style: TextStyle(
                      color: Color(0xffffffff),
                      fontSize: 14.rpx,
                      fontWeight: FontWeight.normal),
                ),
                Text(
                  "/${widget.data?["total"]}",
                  style: TextStyle(
                      color: Color(0xFF999999),
                      fontSize: 14.rpx,
                      fontWeight: FontWeight.normal),
                ),
              ],
            ),
          ),
          SizedBox(height: 6.rpx),
          Text(
            '￥${widget.data?["price"]}',
            style: TextStyle(
                color: Color(0xffffffff),
                fontSize: 14.rpx,
                fontWeight: FontWeight.bold),
          ),
        ],
      ),
    );
  }
}
